function twoSum(nums, target) { 
  let m = new Map();
  for (let i = 0; i < nums.length; i++) { 
    if (m.has(target - nums[i])) {
      console.log(i);
      return [i, m.get(target - nums[i])];
    } else { 
      m.set(nums[i], i);
    }
  }
  return [];
}
console.log(twoSum([2,7,11,15], 9));
console.log(twoSum([3,2,4], 6));